home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2.0 - Programmer's Utilities Power Pack / Delphi 2.0 Programmer's Utilities Power Pack.iso / m_to_r / mailx4 / xchildwi.pa_ / xchildwi.pa
Encoding:
Text File  |  1996-09-15  |  2.8 KB  |  123 lines

  1. unit Childwin;
  2.  
  3. interface
  4.  
  5. uses WinTypes, WinProcs, Classes, Graphics, Forms, Controls, StdCtrls,
  6.   Mailx, VBXCtrl, openMsg;
  7.  
  8. {$I mailxdef.int}
  9.  
  10. type
  11.   TMDIChild = class(TForm)
  12.     MForm1: TMForm;
  13.     MMsg1: TMMsg;
  14.     MsgList: TListBox;
  15.     btnHide: TButton;
  16.     btnOpenMsg: TButton;
  17.     btnRefresh: TButton;
  18.     btnSort: TCheckBox;
  19.     btnUnread: TCheckBox;
  20.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  21.     procedure btnHideClick(Sender: TObject);
  22.     procedure btnRefreshClick(Sender: TObject);
  23.     procedure FormCreate(Sender: TObject);
  24.     procedure btnOpenMsgClick(Sender: TObject);
  25.     procedure NewMsgWnd;
  26.     procedure MsgListDblClick(Sender: TObject);
  27.   private
  28.     { Private declarations }
  29.   public
  30.     { Public declarations }
  31.   end;
  32.  
  33. implementation
  34.  
  35. {$R *.DFM}
  36.  
  37.  
  38. procedure TMDIChild.FormClose(Sender: TObject; var Action: TCloseAction);
  39. begin
  40.   Action := caFree;
  41. end;
  42.  
  43. procedure TMDIChild.btnHideClick(Sender: TObject);
  44. begin
  45.      Close;
  46. end;
  47.  
  48. procedure TMDIChild.btnRefreshClick(Sender: TObject);
  49. begin
  50.      if BtnUnread.State=cbChecked then MMsg1.UnreadOnly:=TRUE
  51.      else MMsg1.UnreadOnly:=FALSE;
  52.  
  53.      if BtnSort.State=cbChecked then MMsg1.SortMsg:=TRUE
  54.      else MMsg1.SortMsg:= FALSE;
  55.      MsgList.Clear;
  56.      MMsg1.Action:= ACTION_FINDFIRST;
  57.  
  58.      While MMsg1.FetchMsg <> 0 Do
  59.      begin
  60.           MsgList.Items.Add(MMsg1.Subject);
  61.           MMsg1.Action:= ACTION_FINDNEXT;
  62.      end;
  63. end;
  64.  
  65. procedure TMDIChild.FormCreate(Sender: TObject);
  66. begin
  67.      btnRefreshClick(Self);
  68. end;
  69.  
  70. procedure TMDIChild.btnOpenMsgClick(Sender: TObject);
  71. var
  72.    Index: Integer;
  73. begin
  74.      Index:= MsgList.ItemIndex;
  75.      if Index=-1 then
  76.      begin
  77.           Application.MessageBox('Select a Mail Message from List',
  78.                                  'Mail X Demo for DELPHI',
  79.                                  MB_ICONSTOP);
  80.      end
  81.      else
  82.      begin
  83.           Mmsg1.FetchMsg:=Index+1;
  84.           NewMsgWnd;
  85.      end;
  86.  
  87. end;
  88.  
  89.  
  90. procedure TMDIChild.NewMsgWnd;
  91. var
  92.    Child: TMsgForm;
  93.    FileNum: Integer;
  94.    Index: Integer;
  95. begin
  96.   Child := TMsgForm.Create(Application);
  97.   Child.MMsg1.MsgID:=MMsg1.MsgID;
  98.   Child.szSubject.Text:=Child.MMsg1.Subject;
  99.   Child.szNoteText.Text:=Child.MMsg1.NoteText;
  100.   Child.szTime.Text:=Child.MMsg1.TimeReceived;
  101.   Child.szMessageID.Text:=Child.MMsg1.MsgID;
  102.   Child.MReci1.FetchRecipient:=TRUE;
  103.   Child.szOriginator.Text:=Child.MReci1.RecipientName;
  104.   Child.MFile1.FetchFile:= True;
  105.   FileNum:= Child.MFile1.FileCount;
  106.  
  107.   For Index:= 1 To FileNum do
  108.   begin
  109.       Child.MFile1.FileNum:= Index;
  110.       Child.szAttachList.Items.Add(Child.MFile1.FileName);
  111.   end;
  112.   If FileNum > 0 Then Child.szAttachList.ItemIndex:= 0;
  113.  
  114. end;
  115.  
  116.  
  117. procedure TMDIChild.MsgListDblClick(Sender: TObject);
  118. begin
  119.      btnOpenMsgClick(Sender);
  120. end;
  121.  
  122. end.
  123.